import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import installElementPlus from './plugins/element'
import { ElMessage, ElMessageBox } from 'element-plus'
// 导入全局样式表
import './assets/css/global.css'
import axios from 'axios'
const app = createApp(App)
app.use(ElMessage)
// 配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 请求拦截.调用回调函数
axios.interceptors.request.use(config => {
  // console.log(config)
  config.headers.Authorization = window.sessionStorage.getItem('token')
  //   必须返回内容 return config
  return config
})
// 全局引用ElMessageBox
app.config.globalProperties.$confirm = ElMessageBox.confirm
// 全局引用http
app.config.globalProperties.$http = axios
// 全局引入ELMessage
app.config.globalProperties.$message = ElMessage
installElementPlus(app)
// 使用路由，并挂载到DOM实例上
app.use(router).mount('#app')
